package onehour.pulsar.examples;

import org.apache.pulsar.client.api.*;

public class OrderCloseConsumer {

    public static void main(String[] args) throws Exception {
        PulsarClient client = PulsarClient.builder()
                .serviceUrl("pulsar://localhost:6650")
                .build();

        Consumer consumer = client.newConsumer(Schema.STRING)
                .topic("dead-order")
                .subscriptionName("dead-order-subscription")
                .subscriptionInitialPosition(SubscriptionInitialPosition.Earliest)
                .subscribe();

        while (true) {

            Message msg = consumer.receive();
            String orderId = (String) msg.getValue();

            System.out.println("close order " + orderId);

        }
    }

}
